<?php

/*
 * This file is part of the Geek-Zoo Projects.
 *
 * @copyright (c) 2010 Geek-Zoo Projects More info http://www.geek-zoo.com
 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License
 * @author xuanyan <xuanyan@geek-zoo.com>
 *
 */


class DatebaseRWProxy
{
    private $db = array();

    function __construct($db_r, $db_w, $initialization = array())
    {
        $this->db = array(
            'r' => $db_r,
            'w' => $db_w
        );
        foreach ($this->db as $val) {
            $val->initialization = $initialization;
        }
    }

    function __call($method, $params)
    {
        switch ($method) {
            case 'getRow':
            case 'getCol':
            case 'getOne':
            case 'getAll':
            
                return call_user_func_array(array($this->db['r'], $method), $params);

                break;
            case 'exec':
            case 'lastInsertId':
            
                return call_user_func_array(array($this->db['w'], $method), $params);

                break;
            default:
                throw new Exception("Please check code for using this method:".$method, 1);
                
                break;
        }
    }
}

?>